{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}/Users/luisl.schenoni/Desktop/MoM.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}27 Aug 2021, 00:10:18

{com}. se MoM.dta
{err}-set MoM.dta- not allowed; 'MoM.dta' not recognized
{txt}{search r(199), local:r(199);}

{com}. 
. ************************************************

. ****** Brazilian Embassies Synth BRAZIL ********

. ************************************************

. 
. ssc install synth, replace all  
{txt}checking {hilite:synth} consistency and verifying not already installed...

copying into {hilite:current directory}...
      copying  {hilite:synth_smoking.dta}
ancillary files successfully copied.

{com}. 
. xtset ccode year
{res}{txt}{col 8}panel variable:  {res}ccode (strongly balanced)
{txt}{col 9}time variable:  {res}{col 25}year, 1990 to 2017
{txt}{col 17}delta:  {res}1 unit

{com}. 
. ** synthetic Brazil

. 
. synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(140) trperiod(2003) xperiod(1990(1)2002) nested fig
{txt}{hline}
{res}Synthetic Control Method for Comparative Case Studies
{txt}{hline}

{res}First Step: Data Setup
{txt}{hline}
{hline}
Data Setup successful
{hline}
{txt}{p 16 28 0} Treated Unit: {res}140 {p_end}
{txt}{p 15 30 0} Control Units: {res}2 20 70 100   160 235 255 325 365 490 560 640 651 740 750 770 850 {p_end}
{txt}{hline}
{txt}{p 10 30 0} Dependent Variable: {res}emb {p_end}
{txt}{p 2 30 0} MSPE minimized for periods: {res}1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002{p_end}
{txt}{p 0 30 0} Results obtained for periods: {res}1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017{p_end}
{txt}{hline}
{txt}{p 18 30 0} Predictors:{res} gdpgth gdp population landmass syst propor leg_majority ideology biodiversity emb(2002) emb(1990){p_end}
{txt}{hline}
{txt}{p 0 30 0} Unless period is specified {p_end}
{txt}{p 0 30 0} predictors are averaged over: {res}1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002{p_end}
{txt}{hline}

{res}Second Step: Run Optimization
{txt}{hline}
{res}{txt}{p 0 30 0} Nested optimization requested {p_end}
{txt}{p 0 30 0} Starting nested optimization module {p_end}
{txt}{p 0 30 0} Optimization done {p_end}
{res}{txt}{hline}
{res}Optimization done
{txt}{hline}

{res}Third Step: Obtain Results
{txt}{hline}
{res}Loss: Root Mean Squared Prediction Error

{txt}{space 0}{hline 9}{c  TT}{hline 11}
{space 0}{space 0}{ralign 8:RMSPE}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 1.802066}}}{space 1}
{space 0}{hline 9}{c  BT}{hline 11}
{hline}
{res}Unit Weights:

{txt}{hline 10}{c TT}{hline 12}
    Co_No {c |} Unit_Weight
{hline 10}{c +}{hline 12}
        2 {c |}           {res}0
       {txt}20 {c |}           {res}0
       {txt}70 {c |}           {res}0
      {txt}100 {c |}           {res}0
      {txt}160 {c |}        {res}.512
      {txt}235 {c |}           {res}0
      {txt}255 {c |}           {res}0
      {txt}325 {c |}           {res}0
      {txt}365 {c |}        {res}.252
      {txt}490 {c |}           {res}0
      {txt}560 {c |}           {res}0
      {txt}640 {c |}           {res}0
      {txt}651 {c |}           {res}0
      {txt}740 {c |}           {res}0
      {txt}750 {c |}           {res}0
      {txt}770 {c |}           {res}0
      {txt}850 {c |}        {res}.236
{txt}{hline 10}{c BT}{hline 12}
{hline}
{res}Predictor Balance:

{txt}{space 0}{hline 31}{c  TT}{hline 11}{hline 11}
{space 0}{space 0}{ralign 30:}{space 1}{c |}{space 1}{ralign 9:Treated}{space 1}{space 1}{ralign 9:Synthetic}{space 1}
{space 0}{hline 31}{c   +}{hline 11}{hline 11}
{space 0}{space 0}{ralign 30:gdpgth}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 186433.6}}}{space 1}{space 1}{ralign 9:{res:{sf: 149633.5}}}{space 1}
{space 0}{space 0}{ralign 30:gdp}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 6.28e+11}}}{space 1}{space 1}{ralign 9:{res:{sf: 2.58e+11}}}{space 1}
{space 0}{space 0}{ralign 30:population}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 1.65e+08}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.03e+08}}}{space 1}
{space 0}{space 0}{ralign 30:landmass}{space 1}{c |}{space 1}{ralign 9:{res:{sf:  8500000}}}{space 1}{space 1}{ralign 9:{res:{sf:  6166000}}}{space 1}
{space 0}{space 0}{ralign 30:syst}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        1}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.274769}}}{space 1}
{space 0}{space 0}{ralign 30:propor}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        1}}}{space 1}{space 1}{ralign 9:{res:{sf:        1}}}{space 1}
{space 0}{space 0}{ralign 30:leg_majority}{space 1}{c |}{space 1}{ralign 9:{res:{sf: .6153846}}}{space 1}{space 1}{ralign 9:{res:{sf: .6141538}}}{space 1}
{space 0}{space 0}{ralign 30:ideology}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        2}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.865538}}}{space 1}
{space 0}{space 0}{ralign 30:biodiversity}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 1.20e+09}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.20e+09}}}{space 1}
{space 0}{space 0}{ralign 30:emb(2002)}{space 1}{c |}{space 1}{ralign 9:{res:{sf:       84}}}{space 1}{space 1}{ralign 9:{res:{sf:   83.892}}}{space 1}
{space 0}{space 0}{ralign 30:emb(1990)}{space 1}{c |}{space 1}{ralign 9:{res:{sf:       79}}}{space 1}{space 1}{ralign 9:{res:{sf:   76.548}}}{space 1}
{space 0}{hline 31}{c  BT}{hline 11}{hline 11}
{hline}
{res}
{com}. 
. 
. 
. 
. xtset ccode year 
{res}{txt}{col 8}panel variable:  {res}ccode (strongly balanced)
{txt}{col 9}time variable:  {res}{col 25}year, 1990 to 2017
{txt}{col 17}delta:  {res}1 unit

{com}. 
. **** STEP 1: predict all placebos ***************

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(2) trperiod(2003) xperiod(1990(1)2002) keep(synth_2, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(20) trperiod(2003) xperiod(1990(1)2002) keep(synth_20, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(160) trperiod(2003) xperiod(1990(1)2002) keep(synth_160, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(235) trperiod(2003) xperiod(1990(1)2002) keep(synth_235, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(255) trperiod(2003) xperiod(1990(1)2002) keep(synth_255, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(325) trperiod(2003) xperiod(1990(1)2002) keep(synth_325, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(365) trperiod(2003) xperiod(1990(1)2002) keep(synth_365, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(490) trperiod(2003) xperiod(1990(1)2002) keep(synth_490, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(560) trperiod(2003) xperiod(1990(1)2002) keep(synth_560, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(640) trperiod(2003) xperiod(1990(1)2002) keep(synth_640, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(651) trperiod(2003) xperiod(1990(1)2002) keep(synth_651, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(740) trperiod(2003) xperiod(1990(1)2002) keep(synth_740, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(750) trperiod(2003) xperiod(1990(1)2002) keep(synth_750, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(770) trperiod(2003) xperiod(1990(1)2002) keep(synth_770, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(850) trperiod(2003) xperiod(1990(1)2002) keep(synth_850, replace)

. 
. qui synth emb gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity emb(2002) emb(1990), trunit(140) trperiod(2003) xperiod(1990(1)2002) keep(synth_140, replace)

. 
. 
. **** STEP 2: predict effects ***

. 
. 
. use synth_2, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_2 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_2

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_2, replace
{txt}file synth_2.dta saved

{com}. 
. 
. use synth_20, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_20 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_20

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_20, replace
{txt}file synth_20.dta saved

{com}. 
. 
. 
. use synth_160, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_160 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_160

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_160, replace
{txt}file synth_160.dta saved

{com}. 
. 
. 
. use synth_235, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_235 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_235

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_235, replace
{txt}file synth_235.dta saved

{com}. 
. 
. 
. use synth_255, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_255 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_255

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_255, replace
{txt}file synth_255.dta saved

{com}. 
. 
. 
. use synth_325, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_325 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_325

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_325, replace
{txt}file synth_325.dta saved

{com}. 
. 
. 
. use synth_365, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_365 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_365

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_365, replace
{txt}file synth_365.dta saved

{com}. 
. 
. 
. use synth_490, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_490 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_490

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_490, replace
{txt}file synth_490.dta saved

{com}. 
. 
. 
. use synth_560, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_560 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_560

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_560, replace
{txt}file synth_560.dta saved

{com}. 
. 
. 
. use synth_651, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_651 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_651

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_651, replace
{txt}file synth_651.dta saved

{com}. 
. 
. 
. use synth_740, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_740 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_740

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_740, replace
{txt}file synth_740.dta saved

{com}. 
. 
. 
. use synth_750, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_750 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_750

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_750, replace
{txt}file synth_750.dta saved

{com}. 
. 
. use synth_770, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_770 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_770

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_770, replace
{txt}file synth_770.dta saved

{com}. 
. 
. 
. use synth_850, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_850 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_850

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_850, replace
{txt}file synth_850.dta saved

{com}. 
. 
. 
. use synth_140, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_140 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_140

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_140, replace
{txt}file synth_140.dta saved

{com}. 
. **** STEP 3: merge all ***

. 
. use synth_2, clear

. qui merge 1:1 years using synth_20, nogenerate

. qui merge 1:1 years using synth_160, nogenerate

. qui merge 1:1 years using synth_235, nogenerate

. qui merge 1:1 years using synth_255, nogenerate

. qui merge 1:1 years using synth_325, nogenerate

. qui merge 1:1 years using synth_365, nogenerate

. qui merge 1:1 years using synth_490, nogenerate

. qui merge 1:1 years using synth_560, nogenerate

. qui merge 1:1 years using synth_651, nogenerate

. qui merge 1:1 years using synth_740, nogenerate

. qui merge 1:1 years using synth_750, nogenerate

. qui merge 1:1 years using synth_770, nogenerate

. qui merge 1:1 years using synth_850, nogenerate

. qui merge 1:1 years using synth_140, nogenerate

. 
. **** STEP 4: line ***

. 
. 
. 
. line tr_effect_2 tr_effect_20 tr_effect_235 tr_effect_255 tr_effect_325 tr_effect_365 tr_effect_490 tr_effect_560 tr_effect_651 tr_effect_740 tr_effect_750 tr_effect_770 tr_effect_850 tr_effect_140 years, lcolor(gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 black) xline(2002) ytitle("Excess Embassies")
{res}
{com}.  
.  
.  
.  clear

.  
. use MoM.dta

. 
. xtset ccode year 
{res}{txt}{col 8}panel variable:  {res}ccode (strongly balanced)
{txt}{col 9}time variable:  {res}{col 25}year, 1990 to 2017
{txt}{col 17}delta:  {res}1 unit

{com}. 
. 
. synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(140) trperiod(2003) xperiod(1990(1)2002) nested fig
{txt}{hline}
{res}Synthetic Control Method for Comparative Case Studies
{txt}{hline}

{res}First Step: Data Setup
{txt}{hline}
{hline}
Data Setup successful
{hline}
{txt}{p 16 28 0} Treated Unit: {res}140 {p_end}
{txt}{p 15 30 0} Control Units: {res}2 20 70 100   160 235 255 325 365 490 560 640 651 740 750 770 850 {p_end}
{txt}{hline}
{txt}{p 10 30 0} Dependent Variable: {res}pko {p_end}
{txt}{p 2 30 0} MSPE minimized for periods: {res}1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002{p_end}
{txt}{p 0 30 0} Results obtained for periods: {res}1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017{p_end}
{txt}{hline}
{txt}{p 18 30 0} Predictors:{res} gdpgth gdp population landmass syst propor leg_majority ideology biodiversity pko(2002) pko(1990){p_end}
{txt}{hline}
{txt}{p 0 30 0} Unless period is specified {p_end}
{txt}{p 0 30 0} predictors are averaged over: {res}1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002{p_end}
{txt}{hline}

{res}Second Step: Run Optimization
{txt}{hline}
{res}{txt}{p 0 30 0} Nested optimization requested {p_end}
{txt}{p 0 30 0} Starting nested optimization module {p_end}
{txt}{p 0 30 0} Optimization done {p_end}
{res}{txt}{hline}
{res}Optimization done
{txt}{hline}

{res}Third Step: Obtain Results
{txt}{hline}
{res}Loss: Root Mean Squared Prediction Error

{txt}{space 0}{hline 9}{c  TT}{hline 11}
{space 0}{space 0}{ralign 8:RMSPE}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 334.7562}}}{space 1}
{space 0}{hline 9}{c  BT}{hline 11}
{hline}
{res}Unit Weights:

{txt}{hline 10}{c TT}{hline 12}
    Co_No {c |} Unit_Weight
{hline 10}{c +}{hline 12}
        2 {c |}         {res}.25
       {txt}20 {c |}           {res}0
       {txt}70 {c |}        {res}.665
      {txt}100 {c |}           {res}0
      {txt}160 {c |}           {res}0
      {txt}235 {c |}           {res}0
      {txt}255 {c |}           {res}0
      {txt}325 {c |}           {res}0
      {txt}365 {c |}        {res}.085
      {txt}490 {c |}           {res}0
      {txt}560 {c |}           {res}0
      {txt}640 {c |}           {res}0
      {txt}651 {c |}           {res}0
      {txt}740 {c |}           {res}0
      {txt}750 {c |}           {res}0
      {txt}770 {c |}           {res}0
      {txt}850 {c |}           {res}0
{txt}{hline 10}{c BT}{hline 12}
{hline}
{res}Predictor Balance:

{txt}{space 0}{hline 31}{c  TT}{hline 11}{hline 11}
{space 0}{space 0}{ralign 30:}{space 1}{c |}{space 1}{ralign 9:Treated}{space 1}{space 1}{ralign 9:Synthetic}{space 1}
{space 0}{hline 31}{c   +}{hline 11}{hline 11}
{space 0}{space 0}{ralign 30:gdpgth}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 186433.6}}}{space 1}{space 1}{ralign 9:{res:{sf:   264367}}}{space 1}
{space 0}{space 0}{ralign 30:gdp}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 6.28e+11}}}{space 1}{space 1}{ralign 9:{res:{sf: 2.44e+12}}}{space 1}
{space 0}{space 0}{ralign 30:population}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 1.65e+08}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.43e+08}}}{space 1}
{space 0}{space 0}{ralign 30:landmass}{space 1}{c |}{space 1}{ralign 9:{res:{sf:  8500000}}}{space 1}{space 1}{ralign 9:{res:{sf:  5175000}}}{space 1}
{space 0}{space 0}{ralign 30:syst}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        1}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.013077}}}{space 1}
{space 0}{space 0}{ralign 30:propor}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        1}}}{space 1}{space 1}{ralign 9:{res:{sf:      .75}}}{space 1}
{space 0}{space 0}{ralign 30:leg_majority}{space 1}{c |}{space 1}{ralign 9:{res:{sf: .6153846}}}{space 1}{space 1}{ralign 9:{res:{sf: .6526923}}}{space 1}
{space 0}{space 0}{ralign 30:ideology}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        2}}}{space 1}{space 1}{ralign 9:{res:{sf: .5603846}}}{space 1}
{space 0}{space 0}{ralign 30:biodiversity}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 1.20e+09}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.20e+09}}}{space 1}
{space 0}{space 0}{ralign 30:pko(2002)}{space 1}{c |}{space 1}{ralign 9:{res:{sf:       77}}}{space 1}{space 1}{ralign 9:{res:{sf:   187.33}}}{space 1}
{space 0}{space 0}{ralign 30:pko(1990)}{space 1}{c |}{space 1}{ralign 9:{res:{sf:       27}}}{space 1}{space 1}{ralign 9:{res:{sf:   11.225}}}{space 1}
{space 0}{hline 31}{c  BT}{hline 11}{hline 11}
{hline}
{res}
{com}.  
. 
. 
. ************************************************

. ****** Brazilian PKOs Synth PLACEBOS ***********

. ************************************************

. 
. xtset ccode year 
{res}{txt}{col 8}panel variable:  {res}ccode (strongly balanced)
{txt}{col 9}time variable:  {res}{col 25}year, 1990 to 2017
{txt}{col 17}delta:  {res}1 unit

{com}. 
. **** STEP 1: predict all placebos ***************

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(2) trperiod(2003) xperiod(1990(1)2002) keep(synth_2, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(20) trperiod(2003) xperiod(1990(1)2002) keep(synth_20, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(160) trperiod(2003) xperiod(1990(1)2002) keep(synth_160, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(235) trperiod(2003) xperiod(1990(1)2002) keep(synth_235, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(255) trperiod(2003) xperiod(1990(1)2002) keep(synth_255, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(325) trperiod(2003) xperiod(1990(1)2002) keep(synth_325, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(365) trperiod(2003) xperiod(1990(1)2002) keep(synth_365, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(490) trperiod(2003) xperiod(1990(1)2002) keep(synth_490, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(560) trperiod(2003) xperiod(1990(1)2002) keep(synth_560, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(640) trperiod(2003) xperiod(1990(1)2002) keep(synth_640, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(651) trperiod(2003) xperiod(1990(1)2002) keep(synth_651, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(740) trperiod(2003) xperiod(1990(1)2002) keep(synth_740, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(750) trperiod(2003) xperiod(1990(1)2002) keep(synth_750, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(770) trperiod(2003) xperiod(1990(1)2002) keep(synth_770, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(850) trperiod(2003) xperiod(1990(1)2002) keep(synth_850, replace)

. 
. qui synth pko gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity pko(2002) pko(1990), trunit(140) trperiod(2003) xperiod(1990(1)2002) keep(synth_140, replace)

. 
. 
. **** STEP 2: predict effects ***

. 
. 
. use synth_2, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_2 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_2

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_2, replace
{txt}file synth_2.dta saved

{com}. 
. 
. use synth_20, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_20 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_20

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_20, replace
{txt}file synth_20.dta saved

{com}. 
. 
. 
. use synth_160, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_160 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_160

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_160, replace
{txt}file synth_160.dta saved

{com}. 
. 
. 
. use synth_235, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_235 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_235

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_235, replace
{txt}file synth_235.dta saved

{com}. 
. 
. 
. use synth_255, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_255 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_255

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_255, replace
{txt}file synth_255.dta saved

{com}. 
. 
. 
. use synth_325, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_325 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_325

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_325, replace
{txt}file synth_325.dta saved

{com}. 
. 
. 
. use synth_365, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_365 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_365

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_365, replace
{txt}file synth_365.dta saved

{com}. 
. 
. 
. use synth_490, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_490 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_490

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_490, replace
{txt}file synth_490.dta saved

{com}. 
. 
. 
. use synth_560, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_560 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_560

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_560, replace
{txt}file synth_560.dta saved

{com}. 
. 
. 
. use synth_651, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_651 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_651

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_651, replace
{txt}file synth_651.dta saved

{com}. 
. 
. 
. use synth_740, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_740 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_740

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_740, replace
{txt}file synth_740.dta saved

{com}. 
. 
. 
. use synth_750, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_750 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_750

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_750, replace
{txt}file synth_750.dta saved

{com}. 
. 
. use synth_770, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_770 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_770

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_770, replace
{txt}file synth_770.dta saved

{com}. 
. 
. 
. use synth_850, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_850 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_850

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_850, replace
{txt}file synth_850.dta saved

{com}. 
. 
. 
. use synth_140, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_140 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_140

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_140, replace
{txt}file synth_140.dta saved

{com}. 
. 
. **** STEP 3: merge all ***

. 
. use synth_2, clear

. qui merge 1:1 years using synth_20, nogenerate

. qui merge 1:1 years using synth_160, nogenerate

. qui merge 1:1 years using synth_235, nogenerate

. qui merge 1:1 years using synth_255, nogenerate

. qui merge 1:1 years using synth_325, nogenerate

. qui merge 1:1 years using synth_365, nogenerate

. qui merge 1:1 years using synth_490, nogenerate

. qui merge 1:1 years using synth_560, nogenerate

. qui merge 1:1 years using synth_651, nogenerate

. qui merge 1:1 years using synth_740, nogenerate

. qui merge 1:1 years using synth_750, nogenerate

. qui merge 1:1 years using synth_770, nogenerate

. qui merge 1:1 years using synth_850, nogenerate

. qui merge 1:1 years using synth_140, nogenerate

. 
. **** STEP 4: line ***

. 
. 
. 
. line tr_effect_2 tr_effect_20 tr_effect_235 tr_effect_255 tr_effect_325 tr_effect_365 tr_effect_490 tr_effect_560 tr_effect_651 tr_effect_740 tr_effect_750 tr_effect_770 tr_effect_850 tr_effect_140 years, lcolor(gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 black) xline(2002)  ytitle("Excess PKOs")
{res}
{com}.  
.  
. clear

.   
.  
. ************************************************

. ******* Brazilian IOs Synth BRAZIL *************

. ************************************************

.  
. use MoM.dta

. 
. xtset ccode year 
{res}{txt}{col 8}panel variable:  {res}ccode (strongly balanced)
{txt}{col 9}time variable:  {res}{col 25}year, 1990 to 2017
{txt}{col 17}delta:  {res}1 unit

{com}. 
. drop if year > 2014
{txt}(54 observations deleted)

{com}. 
. synth io gdpgth gdp population landmass syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(140) trperiod(2003) xperiod(1990(1)2002) nested fig
{txt}{hline}
{res}Synthetic Control Method for Comparative Case Studies
{txt}{hline}

{res}First Step: Data Setup
{txt}{hline}
{hline}
Data Setup successful
{hline}
{txt}{p 16 28 0} Treated Unit: {res}140 {p_end}
{txt}{p 15 30 0} Control Units: {res}2 20 70 100   160 235 255 325 365 490 560 640 651 740 750 770 850 {p_end}
{txt}{hline}
{txt}{p 10 30 0} Dependent Variable: {res}io {p_end}
{txt}{p 2 30 0} MSPE minimized for periods: {res}1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002{p_end}
{txt}{p 0 30 0} Results obtained for periods: {res}1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014{p_end}
{txt}{hline}
{txt}{p 18 30 0} Predictors:{res} gdpgth gdp population landmass syst propor leg_majority ideology biodiversity io(2002) io(1990){p_end}
{txt}{hline}
{txt}{p 0 30 0} Unless period is specified {p_end}
{txt}{p 0 30 0} predictors are averaged over: {res}1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002{p_end}
{txt}{hline}

{res}Second Step: Run Optimization
{txt}{hline}
{res}{txt}{p 0 30 0} Nested optimization requested {p_end}
{txt}{p 0 30 0} Starting nested optimization module {p_end}
{txt}{p 0 30 0} Optimization done {p_end}
{res}{txt}{hline}
{res}Optimization done
{txt}{hline}

{res}Third Step: Obtain Results
{txt}{hline}
{res}Loss: Root Mean Squared Prediction Error

{txt}{space 0}{hline 9}{c  TT}{hline 11}
{space 0}{space 0}{ralign 8:RMSPE}{space 1}{c |}{space 1}{ralign 9:{res:{sf: .9369646}}}{space 1}
{space 0}{hline 9}{c  BT}{hline 11}
{hline}
{res}Unit Weights:

{txt}{hline 10}{c TT}{hline 12}
    Co_No {c |} Unit_Weight
{hline 10}{c +}{hline 12}
        2 {c |}        {res}.007
       {txt}20 {c |}           {res}0
       {txt}70 {c |}           {res}0
      {txt}100 {c |}           {res}0
      {txt}160 {c |}        {res}.254
      {txt}235 {c |}           {res}0
      {txt}255 {c |}           {res}0
      {txt}325 {c |}        {res}.304
      {txt}365 {c |}        {res}.194
      {txt}490 {c |}           {res}0
      {txt}560 {c |}           {res}0
      {txt}640 {c |}           {res}0
      {txt}651 {c |}           {res}0
      {txt}740 {c |}           {res}0
      {txt}750 {c |}        {res}.076
      {txt}770 {c |}           {res}0
      {txt}850 {c |}        {res}.166
{txt}{hline 10}{c BT}{hline 12}
{hline}
{res}Predictor Balance:

{txt}{space 0}{hline 31}{c  TT}{hline 11}{hline 11}
{space 0}{space 0}{ralign 30:}{space 1}{c |}{space 1}{ralign 9:Treated}{space 1}{space 1}{ralign 9:Synthetic}{space 1}
{space 0}{hline 31}{c   +}{hline 11}{hline 11}
{space 0}{space 0}{ralign 30:gdpgth}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 186433.6}}}{space 1}{space 1}{ralign 9:{res:{sf: 181176.5}}}{space 1}
{space 0}{space 0}{ralign 30:gdp}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 6.28e+11}}}{space 1}{space 1}{ralign 9:{res:{sf: 6.17e+11}}}{space 1}
{space 0}{space 0}{ralign 30:population}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 1.65e+08}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.65e+08}}}{space 1}
{space 0}{space 0}{ralign 30:landmass}{space 1}{c |}{space 1}{ralign 9:{res:{sf:  8500000}}}{space 1}{space 1}{ralign 9:{res:{sf:  4734174}}}{space 1}
{space 0}{space 0}{ralign 30:syst}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        1}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.956846}}}{space 1}
{space 0}{space 0}{ralign 30:propor}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        1}}}{space 1}{space 1}{ralign 9:{res:{sf:     .994}}}{space 1}
{space 0}{space 0}{ralign 30:leg_majority}{space 1}{c |}{space 1}{ralign 9:{res:{sf: .6153846}}}{space 1}{space 1}{ralign 9:{res:{sf: .5655385}}}{space 1}
{space 0}{space 0}{ralign 30:ideology}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        2}}}{space 1}{space 1}{ralign 9:{res:{sf:    1.528}}}{space 1}
{space 0}{space 0}{ralign 30:biodiversity}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 1.20e+09}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.20e+09}}}{space 1}
{space 0}{space 0}{ralign 30:io(2002)}{space 1}{c |}{space 1}{ralign 9:{res:{sf:       89}}}{space 1}{space 1}{ralign 9:{res:{sf:   89.204}}}{space 1}
{space 0}{space 0}{ralign 30:io(1990)}{space 1}{c |}{space 1}{ralign 9:{res:{sf:       77}}}{space 1}{space 1}{ralign 9:{res:{sf:   77.087}}}{space 1}
{space 0}{hline 31}{c  BT}{hline 11}{hline 11}
{hline}
{res}
{com}.  
.  
. 
. 
. 
. 
. xtset ccode year 
{res}{txt}{col 8}panel variable:  {res}ccode (strongly balanced)
{txt}{col 9}time variable:  {res}{col 25}year, 1990 to 2014
{txt}{col 17}delta:  {res}1 unit

{com}. 
. **** STEP 1: predict all placebos ***************

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(2) trperiod(2003) xperiod(1990(1)2002) keep(synth_2, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(20) trperiod(2003) xperiod(1990(1)2002) keep(synth_20, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(160) trperiod(2003) xperiod(1990(1)2002) keep(synth_160, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(235) trperiod(2003) xperiod(1990(1)2002) keep(synth_235, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(255) trperiod(2003) xperiod(1990(1)2002) keep(synth_255, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(325) trperiod(2003) xperiod(1990(1)2002) keep(synth_325, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(365) trperiod(2003) xperiod(1990(1)2002) keep(synth_365, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(490) trperiod(2003) xperiod(1990(1)2002) keep(synth_490, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(560) trperiod(2003) xperiod(1990(1)2002) keep(synth_560, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(640) trperiod(2003) xperiod(1990(1)2002) keep(synth_640, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(651) trperiod(2003) xperiod(1990(1)2002) keep(synth_651, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(740) trperiod(2003) xperiod(1990(1)2002) keep(synth_740, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(750) trperiod(2003) xperiod(1990(1)2002) keep(synth_750, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(770) trperiod(2003) xperiod(1990(1)2002) keep(synth_770, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(850) trperiod(2003) xperiod(1990(1)2002) keep(synth_850, replace)

. 
. qui synth io gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity io(2002) io(1990), trunit(140) trperiod(2003) xperiod(1990(1)2002) keep(synth_140, replace)

. 
. 
. **** STEP 2: predict effects ***

. 
. 
. use synth_2, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_2 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_2

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_2, replace
{txt}file synth_2.dta saved

{com}. 
. 
. use synth_20, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_20 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_20

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_20, replace
{txt}file synth_20.dta saved

{com}. 
. 
. 
. use synth_160, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_160 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_160

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_160, replace
{txt}file synth_160.dta saved

{com}. 
. 
. 
. use synth_235, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_235 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_235

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_235, replace
{txt}file synth_235.dta saved

{com}. 
. 
. 
. use synth_255, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_255 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_255

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_255, replace
{txt}file synth_255.dta saved

{com}. 
. 
. 
. use synth_325, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_325 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_325

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_325, replace
{txt}file synth_325.dta saved

{com}. 
. 
. 
. use synth_365, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_365 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_365

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_365, replace
{txt}file synth_365.dta saved

{com}. 
. 
. 
. use synth_490, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_490 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_490

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_490, replace
{txt}file synth_490.dta saved

{com}. 
. 
. 
. use synth_560, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_560 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_560

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_560, replace
{txt}file synth_560.dta saved

{com}. 
. 
. 
. use synth_651, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_651 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_651

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_651, replace
{txt}file synth_651.dta saved

{com}. 
. 
. 
. use synth_740, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_740 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_740

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_740, replace
{txt}file synth_740.dta saved

{com}. 
. 
. 
. use synth_750, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_750 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_750

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_750, replace
{txt}file synth_750.dta saved

{com}. 
. 
. use synth_770, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_770 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_770

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_770, replace
{txt}file synth_770.dta saved

{com}. 
. 
. 
. use synth_850, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_850 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_850

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_850, replace
{txt}file synth_850.dta saved

{com}. 
. 
. 
. use synth_140, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_140 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_140

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_140, replace
{txt}file synth_140.dta saved

{com}. 
. **** STEP 3: merge all ***

. 
. use synth_2, clear

. qui merge 1:1 years using synth_20, nogenerate

. qui merge 1:1 years using synth_160, nogenerate

. qui merge 1:1 years using synth_235, nogenerate

. qui merge 1:1 years using synth_255, nogenerate

. qui merge 1:1 years using synth_325, nogenerate

. qui merge 1:1 years using synth_365, nogenerate

. qui merge 1:1 years using synth_490, nogenerate

. qui merge 1:1 years using synth_560, nogenerate

. qui merge 1:1 years using synth_651, nogenerate

. qui merge 1:1 years using synth_740, nogenerate

. qui merge 1:1 years using synth_750, nogenerate

. qui merge 1:1 years using synth_770, nogenerate

. qui merge 1:1 years using synth_850, nogenerate

. qui merge 1:1 years using synth_140, nogenerate

. 
. **** STEP 4: line ***

. 
. 
. 
. line tr_effect_2 tr_effect_20 tr_effect_235 tr_effect_255 tr_effect_325 tr_effect_365 tr_effect_490 tr_effect_560 tr_effect_651 tr_effect_740 tr_effect_750 tr_effect_770 tr_effect_850 tr_effect_140 years, lcolor(gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 black) xline(2002) ytitle("Excess IGOs")
{res}
{com}.  
.  
. 
.  clear

.  
.  
.  
.  
.  
. ************************************************

. ******* Brazilian AID Synth BRAZIL *************

. ************************************************

.  
. use MoM.dta

. xtset ccode year 
{res}{txt}{col 8}panel variable:  {res}ccode (strongly balanced)
{txt}{col 9}time variable:  {res}{col 25}year, 1990 to 2017
{txt}{col 17}delta:  {res}1 unit

{com}. 
. drop if year > 2013
{txt}(72 observations deleted)

{com}. 
. synth aidprojects gdpgth gdp population landmass syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(140) trperiod(2003) xperiod(1990(1)2002) nested fig
{txt}{hline}
{res}Synthetic Control Method for Comparative Case Studies
{txt}{hline}

{res}First Step: Data Setup
{txt}{hline}
{hline}
Data Setup successful
{hline}
{txt}{p 16 28 0} Treated Unit: {res}140 {p_end}
{txt}{p 15 30 0} Control Units: {res}2 20 70 100   160 235 255 325 365 490 560 640 651 740 750 770 850 {p_end}
{txt}{hline}
{txt}{p 10 30 0} Dependent Variable: {res}aidprojects {p_end}
{txt}{p 2 30 0} MSPE minimized for periods: {res}1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002{p_end}
{txt}{p 0 30 0} Results obtained for periods: {res}1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013{p_end}
{txt}{hline}
{txt}{p 18 30 0} Predictors:{res} gdpgth gdp population landmass syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990){p_end}
{txt}{hline}
{txt}{p 0 30 0} Unless period is specified {p_end}
{txt}{p 0 30 0} predictors are averaged over: {res}1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002{p_end}
{txt}{hline}

{res}Second Step: Run Optimization
{txt}{hline}
{res}{txt}{p 0 30 0} Nested optimization requested {p_end}
{txt}{p 0 30 0} Starting nested optimization module {p_end}
{txt}{p 0 30 0} Optimization done {p_end}
{res}{txt}{hline}
{res}Optimization done
{txt}{hline}

{res}Third Step: Obtain Results
{txt}{hline}
{res}Loss: Root Mean Squared Prediction Error

{txt}{space 0}{hline 9}{c  TT}{hline 11}
{space 0}{space 0}{ralign 8:RMSPE}{space 1}{c |}{space 1}{ralign 9:{res:{sf: .3556287}}}{space 1}
{space 0}{hline 9}{c  BT}{hline 11}
{hline}
{res}Unit Weights:

{txt}{hline 10}{c TT}{hline 12}
    Co_No {c |} Unit_Weight
{hline 10}{c +}{hline 12}
        2 {c |}        {res}.001
       {txt}20 {c |}           {res}0
       {txt}70 {c |}           {res}0
      {txt}100 {c |}           {res}0
      {txt}160 {c |}        {res}.201
      {txt}235 {c |}           {res}0
      {txt}255 {c |}           {res}0
      {txt}325 {c |}           {res}0
      {txt}365 {c |}         {res}.42
      {txt}490 {c |}           {res}0
      {txt}560 {c |}           {res}0
      {txt}640 {c |}           {res}0
      {txt}651 {c |}           {res}0
      {txt}740 {c |}           {res}0
      {txt}750 {c |}           {res}0
      {txt}770 {c |}           {res}0
      {txt}850 {c |}        {res}.377
{txt}{hline 10}{c BT}{hline 12}
{hline}
{res}Predictor Balance:

{txt}{space 0}{hline 31}{c  TT}{hline 11}{hline 11}
{space 0}{space 0}{ralign 30:}{space 1}{c |}{space 1}{ralign 9:Treated}{space 1}{space 1}{ralign 9:Synthetic}{space 1}
{space 0}{hline 31}{c   +}{hline 11}{hline 11}
{space 0}{space 0}{ralign 30:gdpgth}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 186433.6}}}{space 1}{space 1}{ralign 9:{res:{sf: 179407.5}}}{space 1}
{space 0}{space 0}{ralign 30:gdp}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 6.28e+11}}}{space 1}{space 1}{ralign 9:{res:{sf: 2.80e+11}}}{space 1}
{space 0}{space 0}{ralign 30:population}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 1.65e+08}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.45e+08}}}{space 1}
{space 0}{space 0}{ralign 30:landmass}{space 1}{c |}{space 1}{ralign 9:{res:{sf:  8500000}}}{space 1}{space 1}{ralign 9:{res:{sf:  8428700}}}{space 1}
{space 0}{space 0}{ralign 30:syst}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        1}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.440615}}}{space 1}
{space 0}{space 0}{ralign 30:propor}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        1}}}{space 1}{space 1}{ralign 9:{res:{sf:     .998}}}{space 1}
{space 0}{space 0}{ralign 30:leg_majority}{space 1}{c |}{space 1}{ralign 9:{res:{sf: .6153846}}}{space 1}{space 1}{ralign 9:{res:{sf: .5095385}}}{space 1}
{space 0}{space 0}{ralign 30:ideology}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        2}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.875538}}}{space 1}
{space 0}{space 0}{ralign 30:biodiversity}{space 1}{c |}{space 1}{ralign 9:{res:{sf: 1.20e+09}}}{space 1}{space 1}{ralign 9:{res:{sf: 1.20e+09}}}{space 1}
{space 0}{space 0}{ralign 30:aidprojects(2002)}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        0}}}{space 1}{space 1}{ralign 9:{res:{sf:     .173}}}{space 1}
{space 0}{space 0}{ralign 30:aidprojects(1990)}{space 1}{c |}{space 1}{ralign 9:{res:{sf:        0}}}{space 1}{space 1}{ralign 9:{res:{sf:     .112}}}{space 1}
{space 0}{hline 31}{c  BT}{hline 11}{hline 11}
{hline}
{res}
{com}. 
. 
. 
. 
. ************************************************

. ********* Brazilian AID Synth PLACEBOS *********

. ************************************************

. 
. xtset ccode year 
{res}{txt}{col 8}panel variable:  {res}ccode (strongly balanced)
{txt}{col 9}time variable:  {res}{col 25}year, 1990 to 2013
{txt}{col 17}delta:  {res}1 unit

{com}. 
. **** STEP 1: predict all placebos ***************

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(2) trperiod(2003) xperiod(1990(1)2002) keep(synth_2, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(20) trperiod(2003) xperiod(1990(1)2002) keep(synth_20, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(160) trperiod(2003) xperiod(1990(1)2002) keep(synth_160, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(235) trperiod(2003) xperiod(1990(1)2002) keep(synth_235, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(255) trperiod(2003) xperiod(1990(1)2002) keep(synth_255, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(325) trperiod(2003) xperiod(1990(1)2002) keep(synth_325, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(365) trperiod(2003) xperiod(1990(1)2002) keep(synth_365, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(490) trperiod(2003) xperiod(1990(1)2002) keep(synth_490, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(560) trperiod(2003) xperiod(1990(1)2002) keep(synth_560, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(640) trperiod(2003) xperiod(1990(1)2002) keep(synth_640, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(651) trperiod(2003) xperiod(1990(1)2002) keep(synth_651, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(740) trperiod(2003) xperiod(1990(1)2002) keep(synth_740, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(750) trperiod(2003) xperiod(1990(1)2002) keep(synth_750, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(770) trperiod(2003) xperiod(1990(1)2002) keep(synth_770, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(850) trperiod(2003) xperiod(1990(1)2002) keep(synth_850, replace)

. 
. qui synth aidprojects gdpgth gdp population landmass  syst propor leg_majority ideology biodiversity aidprojects(2002) aidprojects(1990), trunit(140) trperiod(2003) xperiod(1990(1)2002) keep(synth_140, replace)

. 
. 
. **** STEP 2: predict effects ***

. 
. 
. use synth_2, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_2 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_2

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_2, replace
{txt}file synth_2.dta saved

{com}. 
. 
. use synth_20, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_20 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_20

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_20, replace
{txt}file synth_20.dta saved

{com}. 
. 
. 
. use synth_160, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_160 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_160

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_160, replace
{txt}file synth_160.dta saved

{com}. 
. 
. 
. use synth_235, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_235 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_235

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_235, replace
{txt}file synth_235.dta saved

{com}. 
. 
. 
. use synth_255, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_255 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_255

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_255, replace
{txt}file synth_255.dta saved

{com}. 
. 
. 
. use synth_325, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_325 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_325

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_325, replace
{txt}file synth_325.dta saved

{com}. 
. 
. 
. use synth_365, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_365 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_365

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_365, replace
{txt}file synth_365.dta saved

{com}. 
. 
. 
. use synth_490, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_490 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_490

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_490, replace
{txt}file synth_490.dta saved

{com}. 
. 
. 
. use synth_560, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_560 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_560

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_560, replace
{txt}file synth_560.dta saved

{com}. 
. 
. 
. use synth_651, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_651 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_651

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_651, replace
{txt}file synth_651.dta saved

{com}. 
. 
. 
. use synth_740, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_740 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_740

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_740, replace
{txt}file synth_740.dta saved

{com}. 
. 
. 
. use synth_750, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_750 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_750

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_750, replace
{txt}file synth_750.dta saved

{com}. 
. 
. use synth_770, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_770 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_770

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_770, replace
{txt}file synth_770.dta saved

{com}. 
. 
. 
. use synth_850, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_850 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_850

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_850, replace
{txt}file synth_850.dta saved

{com}. 
. 
. 
. use synth_140, clear

. 
. rename _time years
{res}
{com}. 
. gen tr_effect_140 = _Y_treated - _Y_synthetic

. 
. keep years tr_effect_140

. 
. drop if missing(years)
{txt}(0 observations deleted)

{com}. 
. save synth_140, replace
{txt}file synth_140.dta saved

{com}. 
. **** STEP 3: merge all ***

. 
. use synth_2, clear

. qui merge 1:1 years using synth_20, nogenerate

. qui merge 1:1 years using synth_160, nogenerate

. qui merge 1:1 years using synth_235, nogenerate

. qui merge 1:1 years using synth_255, nogenerate

. qui merge 1:1 years using synth_325, nogenerate

. qui merge 1:1 years using synth_365, nogenerate

. qui merge 1:1 years using synth_490, nogenerate

. qui merge 1:1 years using synth_560, nogenerate

. qui merge 1:1 years using synth_651, nogenerate

. qui merge 1:1 years using synth_740, nogenerate

. qui merge 1:1 years using synth_750, nogenerate

. qui merge 1:1 years using synth_770, nogenerate

. qui merge 1:1 years using synth_850, nogenerate

. qui merge 1:1 years using synth_140, nogenerate

. 
. **** STEP 4: line ***

. 
. 
. 
. line tr_effect_2 tr_effect_20 tr_effect_235 tr_effect_255 tr_effect_325 tr_effect_365 tr_effect_490 tr_effect_560 tr_effect_651 tr_effect_740 tr_effect_750 tr_effect_770 tr_effect_850 tr_effect_140 years, lcolor(gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 gs12 black) xline(2002) ytitle("Excess Aid Projects")
{res}
{com}.  
.  
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}/Users/luisl.schenoni/Desktop/MoM.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}27 Aug 2021, 00:17:47
{txt}{.-}
{smcl}
{txt}{sf}{ul off}